/*
 * InformationFond.cpp
 *
 *  Created on: 05.11.2013
 *      Author: ulgish
 */

#include <lab4/InformationFond.h>

namespace DT {

InformationFond::InformationFond() {

	bufer.str("Hello World\n");
	pthread_rwlock_init(&rwlock, NULL);
}

    std::string  InformationFond::read()
    {
    	std::string ret;
    	pthread_rwlock_rdlock(&rwlock);
    	ret = bufer.str();
    	pthread_rwlock_unlock(&rwlock);
    	return std::string(ret);
    }

    void InformationFond::write(const std::string & str)
    {
    	pthread_rwlock_wrlock(&rwlock);
    	bufer.str(str.c_str());
    	pthread_rwlock_unlock(&rwlock);
    }

InformationFond::~InformationFond() {
	pthread_rwlock_destroy(&rwlock);
}

}
